{namespace form=TYPO3\CMS\Form\ViewHelpers}

<f:if condition="{model.showElement}">
	<f:format.raw>{model.layout.elementOuterWrap.0}</f:format.raw>
		<ol>
</f:if>
		<f:for each="{form:aggregateSelectOptions(model:model)}" as="option">
			<f:if condition="{option.options}">
				<f:then>
						<f:for each="{option.options}" as="optgroupOption">
							<f:if condition="{optgroupOption.selected}">
								<f:if condition="{model.showElement}">
									<f:format.raw>{model.layout.optionOuterWrap.0}</f:format.raw>{optgroupOption.label}<f:format.raw>{model.layout.optionOuterWrap.1}</f:format.raw>
								</f:if>
								<f:if condition="{model.additionalArguments.multiple}">
									<f:then>
										<f:form.hidden
											class="{model.additionalArguments.class}"
											dir="{model.additionalArguments.dir}"
											id="{model.additionalArguments.id}"
											lang="{model.additionalArguments.lang}"
											style="{model.additionalArguments.style}"
											title="{model.additionalArguments.title}"
											accesskey="{model.additionalArguments.accesskey}"
											tabindex="{model.additionalArguments.tabindex}"
											onclick="{model.additionalArguments.onclick}"

											name="{model.additionalArguments.prefix}[{model.additionalArguments.name}][]"
											value="{option.value}"

											additionalAttributes="{model.htmlAttributes}"
										/>
									</f:then>
									<f:else>
										<f:form.hidden
											class="{model.additionalArguments.class}"
											dir="{model.additionalArguments.dir}"
											id="{model.additionalArguments.id}"
											lang="{model.additionalArguments.lang}"
											style="{model.additionalArguments.style}"
											title="{model.additionalArguments.title}"
											accesskey="{model.additionalArguments.accesskey}"
											tabindex="{model.additionalArguments.tabindex}"
											onclick="{model.additionalArguments.onclick}"

											name="{model.additionalArguments.prefix}[{model.additionalArguments.name}]"
											value="{option.value}"

											additionalAttributes="{model.htmlAttributes}"
										/>
									</f:else>
								</f:if>
							</f:if>
						</f:for>
				</f:then>
				<f:else>
					<f:if condition="{option.selected}">
						<f:if condition="{model.showElement}">
							<f:format.raw>{model.layout.optionOuterWrap.0}</f:format.raw>{option.label}<f:format.raw>{model.layout.optionOuterWrap.1}</f:format.raw>
						</f:if>
						<f:if condition="{model.additionalArguments.multiple}">
							<f:then>
								<f:form.hidden
									class="{model.additionalArguments.class}"
									dir="{model.additionalArguments.dir}"
									id="{model.additionalArguments.id}"
									lang="{model.additionalArguments.lang}"
									style="{model.additionalArguments.style}"
									title="{model.additionalArguments.title}"
									accesskey="{model.additionalArguments.accesskey}"
									tabindex="{model.additionalArguments.tabindex}"
									onclick="{model.additionalArguments.onclick}"

									name="{model.additionalArguments.prefix}[{model.additionalArguments.name}][]"
									value="{option.value}"

									additionalAttributes="{model.htmlAttributes}"
								/>
							</f:then>
							<f:else>
								<f:form.hidden
									class="{model.additionalArguments.class}"
									dir="{model.additionalArguments.dir}"
									id="{model.additionalArguments.id}"
									lang="{model.additionalArguments.lang}"
									style="{model.additionalArguments.style}"
									title="{model.additionalArguments.title}"
									accesskey="{model.additionalArguments.accesskey}"
									tabindex="{model.additionalArguments.tabindex}"
									onclick="{model.additionalArguments.onclick}"

									name="{model.additionalArguments.prefix}[{model.additionalArguments.name}]"
									value="{option.value}"

									additionalAttributes="{model.htmlAttributes}"
								/>
							</f:else>
						</f:if>
					</f:if>
				</f:else>
			</f:if>
		</f:for>
<f:if condition="{model.showElement}">
		</ol>
	<f:format.raw>{model.layout.elementOuterWrap.1}</f:format.raw>
</f:if>